package com.shop.cereshop.business.controller;

import com.shop.cereshop.business.page.businessdata.PendingPayOrderVO;
import com.shop.cereshop.business.page.businessdata.OrderTrendVO;
import com.shop.cereshop.business.page.businessdata.OverviewVO;
import com.shop.cereshop.business.page.businessdata.OldCustomerDataVO;
import com.shop.cereshop.business.param.businessdata.OverviewParam;
import com.shop.cereshop.business.service.shop.ShopBusinessDataService;
import com.shop.cereshop.business.utils.ContextUtil;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @description: 首页二级-经营数据
 * @author zdd
 * @date 2025/9/17 13:21
 * @version 1.0
 */
@RestController
@RequestMapping("/business/data")
@Slf4j(topic = "ShopBusinessDataController")
@Api(value = "首页二级-经营数据", tags = "首页二级-经营数据")
public class ShopBusinessDataController {

    @Resource
    private ShopBusinessDataService shopBusinessDataService;

    @ApiOperation(value = "交易概况")
    @PostMapping(value = "/overview")
    public Result<OverviewVO> overview(@Validated @RequestBody OverviewParam param) throws CoBusinessException {
        param.setShopId(ContextUtil.getShopId());
//        param.setShopId(2L);
        OverviewVO vo = shopBusinessDataService.overview(param);
        return new Result(vo);
    }

    @ApiOperation(value = "订单趋势")
    @PostMapping(value = "/orderTrend")
    public Result<OrderTrendVO> orderTrend(@Validated @RequestBody OverviewParam param) throws CoBusinessException {
        param.setShopId(ContextUtil.getShopId());
//        param.setShopId(2L);
        OrderTrendVO vo = shopBusinessDataService.orderTrend(param);
        return new Result(vo);
    }

    @ApiOperation(value = "订单数据")
    @PostMapping(value = "/pendingOrder")
    public Result<PendingPayOrderVO> pendingPayOrderData(@Validated @RequestBody OverviewParam param) throws CoBusinessException {
        param.setShopId(ContextUtil.getShopId());
//        param.setShopId(2L);
        PendingPayOrderVO vo = shopBusinessDataService.pendingOrderData(param);
        return new Result(vo);
    }

    @ApiOperation(value = "老客户交易数据")
    @PostMapping(value = "/oldCustomerData")
    public Result<OldCustomerDataVO> oldCustomerData(@Validated @RequestBody OverviewParam param) throws CoBusinessException {
        param.setShopId(ContextUtil.getShopId());
//        param.setShopId(2L);
        OldCustomerDataVO vo = shopBusinessDataService.oldCustomerData(param);
        return new Result(vo);
    }


}
